package hongcaosp.app.android.modle.impl;

import android.text.TextUtils;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpParams;

import hongcaosp.app.android.BuildConfig;
import hongcaosp.app.android.modle.BaseResponse;
import hongcaosp.app.android.modle.DataCallBack;
import hongcaosp.app.android.modle.bean.Comment;
import hongcaosp.app.android.modle.bean.CommentReply;
import hongcaosp.app.android.modle.bean.CommentWrapper;
import hongcaosp.app.android.modle.bean.Pagebean;
import hongcaosp.app.android.modle.mi.CommentModle;

public class CommentModleImpl implements CommentModle {
    @Override
    public void videoComments(String token,int videoId, int pageSize, int pageNum, DataCallBack<Pagebean<Comment>> callBack) {
        HttpParams params = new HttpParams();
        params.put("id", videoId);
        if (!TextUtils.isEmpty(token)) {
            params.put("token", token);
        }
        params.put("pageSize", pageSize);
        params.put("pageNumber", pageNum);
        OkGo.<BaseResponse>post(BuildConfig.HOST + "/api/videoComments").params(params).execute(callBack);
    }

    @Override
    public void videoCommentsChildren(String token,int commentId, int pageSize, int pageNum, DataCallBack<Pagebean<CommentReply>> callBack) {
        HttpParams params = new HttpParams();
        params.put("id", commentId);
        if (!TextUtils.isEmpty(token)) {
            params.put("token", token);
        }
        params.put("pageSize", pageSize);
        params.put("pageNumber", pageNum);
        OkGo.<BaseResponse>post(BuildConfig.HOST + "/api/videoCommentsChildren").params(params).execute(callBack);
    }

    @Override
    public void replyComments(String token, int type, int videoId, int commentsId, String content, DataCallBack<CommentWrapper<CommentReply>> callBack) {
        HttpParams params = new HttpParams();
        params.put("token", token);
        params.put("type", type);
        params.put("id", videoId);
        params.put("commentsId", commentsId);
        params.put("content", content);
        OkGo.<BaseResponse>post(BuildConfig.HOST + "/api/comments/replyComments").params(params).execute(callBack);
    }

    @Override
    public void commentVideo(String token, int type, int videoId, String content, DataCallBack<CommentWrapper<Comment>> callBack) {
        HttpParams params = new HttpParams();
        params.put("token", token);
        params.put("type", type);
        params.put("id", videoId);
        params.put("content", content);
        OkGo.<BaseResponse>post(BuildConfig.HOST + "/api/comments/replyComments").params(params).execute(callBack);
    }

    @Override
    public void deleteComments(String token, int commentsId, DataCallBack dataCallBack) {
        HttpParams params = new HttpParams();
        params.put("token", token);
        params.put("id", commentsId);
        OkGo.<BaseResponse>post(BuildConfig.HOST + "/api/comments/delete").params(params).execute(dataCallBack);
    }

    @Override
    public void likeComment(String token, int commentsId, DataCallBack dataCallBack) {
        HttpParams params = new HttpParams();
        params.put("token", token);
        params.put("id", commentsId);
        OkGo.<BaseResponse>post(BuildConfig.HOST + "/api/comments/commentsLike").params(params).execute(dataCallBack);
    }

    @Override
    public void likeCommentCancel(String token, int commentsId, DataCallBack dataCallBack) {
        HttpParams params = new HttpParams();
        params.put("token", token);
        params.put("id", commentsId);
        OkGo.<BaseResponse>post(BuildConfig.HOST + "/api/comments/commentsLikeCancle").params(params).execute(dataCallBack);
    }
}
